package com.ruoyi.develop.factory.factoryTestMachineryHammer.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.develop.factory.factoryProductStore.domain.FactoryProductStore;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.develop.factory.factoryTestMachineryHammer.domain.FactoryTestMachineryHammer;
import com.ruoyi.develop.factory.factoryTestMachineryHammer.service.IFactoryTestMachineryHammerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出厂试验-机械试验-防振锤Controller
 * @author lmm
 * @date 2024-11-05
 */
@RestController
@RequestMapping("/factoryTestMachineryHammer/factoryTestMachineryHammer")
public class FactoryTestMachineryHammerController extends BaseController {
    @Autowired
    private IFactoryTestMachineryHammerService factoryTestMachineryHammerService;

    /**
     * 查询出厂试验-机械试验-防振锤列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryTestMachineryHammer:query')")
    @GetMapping("/list")
    public TableDataInfo list(FactoryTestMachineryHammer entity) {
        startPage();
        List<FactoryTestMachineryHammer> list = factoryTestMachineryHammerService.selectList(entity);
        return getDataTable(list);
    }


    /**
     * 根据到货查询-机械试验-防振锤列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryProductStore:query')")
    @GetMapping("/listByFahuoDetail")
    public TableDataInfo listByFahuoDetail(FactoryTestMachineryHammer entity) {
        startPage();
        List<FactoryTestMachineryHammer> list = factoryTestMachineryHammerService.selectListByFahuoDetail(entity);
        return getDataTable(list);
    }


    /**
     * 导出出厂试验-机械试验-防振锤列表
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryTestMachineryHammer:export')")
    @Log(title = "出厂试验-机械试验-防振锤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FactoryTestMachineryHammer entity) {
        List<FactoryTestMachineryHammer> list = factoryTestMachineryHammerService.selectList(entity);
        ExcelUtil<FactoryTestMachineryHammer> util = new ExcelUtil<FactoryTestMachineryHammer>(FactoryTestMachineryHammer. class);
        util.exportExcel(response, list, "出厂试验-机械试验-防振锤数据");
    }

    /**
     * 获取出厂试验-机械试验-防振锤详细信息
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryTestMachineryHammer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(factoryTestMachineryHammerService.selectById(id));
    }

    /**
     * 新增出厂试验-机械试验-防振锤
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryTestMachineryHammer:add')")
    @Log(title = "出厂试验-机械试验-防振锤", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody FactoryTestMachineryHammer entity) {
        return toAjax(factoryTestMachineryHammerService.insert(entity));
    }

    /**
     * 修改出厂试验-机械试验-防振锤
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryTestMachineryHammer:edit')")
    @Log(title = "出厂试验-机械试验-防振锤", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody FactoryTestMachineryHammer entity) {
        return toAjax(factoryTestMachineryHammerService.update(entity));
    }

    /**
     * 删除出厂试验-机械试验-防振锤
     */
    @PreAuthorize("@ss.hasPermi('develop:FactoryTestMachineryHammer:remove')")
    @Log(title = "出厂试验-机械试验-防振锤", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(factoryTestMachineryHammerService.deleteByIds(ids));
    }
}
